Repository navigation
Let an enum with no registered class take any enum value - #504
Merged
Merged
Conversation
#492 gave HX_DO_ENUM_RTTI _hx_isEnumValueOf, which compares a value's class with the enum's own __mClass, and returned false when __mClass is null. An extern enum written by hand in C++, as Haxe's unit.issues.Issue10830 does, never registers its class, so every value of it failed its own check: the switch in that test threw Invalid Cast, and so would a typed catch of it or a cast to it. 6.0.2 shipped with it, since the haxe unit job runs only on pushes to main. An enum whose __mClass is null takes any enum value again, through the clsIdEnum check every enum used before #492. Enums Haxe generates have their class, and still check for their own. EnumUnregisteredClass is Issue10830's extern enum, with a switch, a cast from Dynamic and a typed catch, and checks that generated enums still tell each other apart. It threw Invalid Cast before this change. Tests: EnumUnregisteredClass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For 6.0.3. Fixes a regression in 6.0.2 from #492.
Main's full CI on 35cede7 failed "haxe unit" on all five platforms with the same single error:
Cause
#492 gave
HX_DO_ENUM_RTTI_hx_isEnumValueOf, which compares a value's class with the enum's own__mClass, and it returned false when__mClassis null. An extern enum written by hand in C++, as Issue10830 does, usesHX_DO_ENUM_RTTIbut never registers its class, so every value of it failed its own check. The switch in that test threw Invalid Cast, and so would a typed catch of it or a cast to it.6.0.2 shipped with it. The haxe unit job runs only on pushes to main, and main's push runs after #492 were cancelled to free runners, so 35cede7's was the first to reach it.
Change
An enum whose
__mClassis null takes any enum value again, through theclsIdEnumcheck every enum used before #492. Enums Haxe generates register their class, and still check for their own. The change is one expression ininclude/hx/Macros.handinclude/hx/MacrosFixed.h, plus a sentence in the comment ininclude/hx/Object.h.Tests
test/regression/EnumUnregisteredClassis Issue10830's extern enum, with a switch, a cast from Dynamic and a typed catch. It also checks that two generated enums still tell each other apart. Without the change it stops with "Invalid Cast"; with it, it prints the expected output. Run on 64-bit Windows with MSVC and Haxe 4.3.7.Haxe 4.3.7's unit suite, which PR CI does not run, passes against this branch on 64-bit Windows with MSVC: 11025 of 11025 assertions, Issue10830 included. The branch is on main at b6981ce, so that run covers every 6.0.3 change so far.